// 引入发送请求的接口函数
import request from "@/utils/request";
import type {
  GetTrademarkListRes,
  TrademarkItem,
  TrademarkList,
} from "./model/trademarkModel";

enum Api {
  getTrademarkListUrl = "/admin/product/baseTrademark",
  getAllTrademarkListUrl = "/admin/product/baseTrademark/getTrademarkList",
  addTrademarkUrl = "/admin/product/baseTrademark/save",
  updateTrademarkUrl = "/admin/product/baseTrademark/update",
  deleteTrademarkUrl = "/admin/product/baseTrademark/remove",
  // getBaseTrademarkUrl = "/admin/product/baseTrademark/get",
}

// 请求获取品牌管理相关的接口函数
export const getTrademarkListApi = (page: number, limit: number) => {
  return request.get<any, GetTrademarkListRes>(
    Api.getTrademarkListUrl + `/${page}/${limit}`
  );
};

// 请求获取所有品牌管理相关的接口函数
export const getAllTrademarkListApi = () => {
  return request.get<any, TrademarkList>(Api.getAllTrademarkListUrl);
};

// 请求获取点击添加新增一条trademark的接口函数
export const addTrademarkApi = (tmName: string, logoUrl: string) => {
  return request.post<any, null>(Api.addTrademarkUrl, { tmName, logoUrl });
};

// 请求获取点击添加新增一条trademark的接口函数
// export const getBaseTrademarkApi = (id: number) => {
//   return request.get<any, TrademarkItem>(Api.getBaseTrademarkUrl + `/${id}`);
// };

// 请求获取新增一条trademark的接口函数
// export const updateTrademarkApi = (trademark: TradeUpdateData) => {
//   return request.put(Api.updateTrademarkUrl, { trademark });
// };
export const updateTrademarkApi = (tm: TrademarkItem) => {
  return request.put(Api.updateTrademarkUrl, tm);
};
// export const updateTrademarkApi = (trademark: TrademarkItem) => {
//   return request.put(Api.updateTrademarkUrl, { trademark });
// };

// 请求获取删除一条数据的接口函数
export const deleteTrademarkApi = (id: number) => {
  return request.delete<any, null>(Api.deleteTrademarkUrl + `/${id}`);
};
